## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'janitor'
##
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
## Warning: package 'sf' was built under R version 4.4.2
## Linking to GEOS 3.12.2, GDAL 3.9.3, PROJ 9.4.1; sf_use_s2() is TRUE
## Warning: package 'sp' was built under R version 4.4.2
## Warning: package 'raster' was built under R version 4.4.2
##
## Attaching package: 'raster'
##
## The following object is masked from 'package:dplyr':
##
## select
## Warning: package 'geojsonR' was built under R version 4.4.2
##
## Attaching package: 'glue'
##
## The following object is masked from 'package:raster':
##
## trim
## Warning: package 'lwgeom' was built under R version 4.4.2
## Linking to liblwgeom 3.0.0beta1 r16016, GEOS 3.13.0, PROJ 9.5.1
## Warning in fun(libname, pkgname): GEOS versions differ: lwgeom has 3.13.0 sf
## has 3.12.2
## Warning in fun(libname, pkgname): PROJ versions differ: lwgeom has 9.5.1 sf has
## 9.4.1
##
## Attaching package: 'lwgeom'
##
## The following object is masked from 'package:sf':
##
## st_perimeter
## Reading layer `hex_merged_w_stats' from data source
## `C:\Users\hbaue\OneDrive - The University of Chicago\Documents\GitHub\pre_1965\data\mst\hex_merged_w_stats.gpkg'
## using driver `GPKG'
## Simple feature collection with 110014 features and 53 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: -87.94612 ymin: 41.63934 xmax: -87.51956 ymax: 42.02957
## Geodetic CRS: WGS 84
## Warning: No shared levels found between `names(values)` of the manual scale and the
## data's colour values.
## Warning: No shared levels found between `names(values)` of the manual scale and the
## data's colour values.
Calculate the change of total homicides over 5 year periods, the change of average homicides over 5 year periods, and the change of average homicide rate over 5 year periods.
Define Notable Decline or Rise as change in the upper 10 percent of declines or rises within year.
## [1] "year_riot"
## [1] "in_check"
## [1] "still_desi"
## [1] "def_decl"
## [1] "hazardous"
## [1] "industrial"
## [1] "best"
## [1] "commercial"
## [1] "bk_res_1"
## [1] "bk_res_2"
## [1] "bk_res_3"
## [1] "bk_res_4_1"
## [1] "bk_res_4_2"
## [1] "bk_res_4_3"
## [1] "bk_res_5_1"
## [1] "bk_res_5_2"
## [1] "bk_res_5_3"
We see polygons where the percentage of 1% concentration is lower than 10% or 90%. There are very few instances where the difference is large (more than 10 percentage points difference in area mapped), and most occur in the south of Chicago where the maps were a) most distorted and b) the least amount of development matches the present state.
It may be best to use the 90% value rather than the 10% or 1% value in these instances. This is further corroborated by the original maps. The areas plotted below where the difference is highest appear to be of fairly equal size in all three maps.
test <- df %>%
filter(year == 1950) %>%
filter(bk_res_3 < bk_res_2 | bk_res_2 < bk_res_1 | bk_res_3 < bk_res_1) %>%
dplyr::select(GRID_ID, bk_res_1, bk_res_2, bk_res_3) %>%
mutate(diff_1_2 = bk_res_1 - bk_res_2,
diff_1_3 = bk_res_1 - bk_res_3,
diff_2_3 = bk_res_2 - bk_res_3) %>%
pivot_longer(cols = contains("diff")) %>%
filter(value > 0.1)
test
ggplot(data = test ) +
geom_sf(aes(fill = GRID_ID)) +
coord_sf(
xlim = c(-87.94011, -87.52398), # Approximate longitude bounds of Chicago
ylim = c(41.64454, 42.02304) # Approximate latitude bounds of Chicago
)